/**
 * 作者：陈文斌 on 2019/1/7.
 * 邮箱：chen_wennbin@163.com
 * 版本：v1.0
 */

import 'package:flutter/material.dart';
import 'package:crm/constant/constant.dart';
import 'package:crm/model/ClientManager/client_info_model.dart';

class ClientInfoSection extends StatelessWidget {
  final ClientInfoModel clientInfo;

  ClientInfoSection({
    Key key,
    @required this.clientInfo,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: AppScreen.setWidth(375),
      height: 90,
      color: Colors.white,
      padding: EdgeInsets.fromLTRB(17, 17, 0, 17),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              CompanyNameSection(clientInfo.companyName ?? ''),
              Padding(padding: EdgeInsets.only(top: 11)),
              PhoneSection(clientInfo.phone ?? ''),
            ],
          ),
          BusinessCard(),
        ],
      ),
    );
  }
}

Widget CompanyNameSection(String companyName) {
  return Row(
    children: <Widget>[
      Container(
        margin: EdgeInsets.only(right: 8),
        child: Text(
          companyName,
          style: TextStyle(
            color: AppColors.TextColor,
            fontSize: AppFontSizes.Font18,
            fontFamily: AppFontFamilies.PingFangSC,
            fontWeight: FontWeight.w700,
          ),
        ),
      ),
      Container(
        height: 25,
        alignment: Alignment.centerLeft,
        child: Image.asset(
          '' == '企业'
              ? 'images/ic_shop_search.png'
              : 'images/ic_business_search.png',
          width: 30,
          height: 16,
          fit: BoxFit.fill,
        ),
      ),
    ],
  );
}

Widget PhoneSection(String phone) {
  return Row(
    children: <Widget>[
      Container(
        height: 18,
        margin: EdgeInsets.only(right: 23),
        child: Text(
          '联系电话 ' + phone,
          style: TextStyle(color: AppColors.TextColor),
        ),
      ),
      Container(
        width: 18,
        height: 18,
        decoration: BoxDecoration(
          color: Color(0xFF00BE98),
          borderRadius: BorderRadius.circular(9),
        ),
      ),
    ],
  );
}

Widget BusinessCard() {
  return GestureDetector(
    onTap: (){
      print('公司名片');
    },
    child: Container(
      width: 80,
      height: 20,
      decoration: BoxDecoration(
        gradient: LinearGradient(
          colors: [
            Color(0xFFFEBE55),
            Color(0xFFFF9644),
          ],
        ),
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(10),
          bottomLeft: Radius.circular(10),
        ),
      ),
      child: Row(
        children: <Widget>[
          Container(
            width: 12,
            height: 12,
            margin: EdgeInsets.all(4),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(6),
              color: Colors.white,
            ),
          ),
          Text(
            '公司名片',
            style: TextStyle(
              color: Colors.white,
              fontSize: 9,
              fontFamily: AppFontFamilies.PingFangSC,
              fontWeight: FontWeight.w500,
            ),
          ),
        ],
      ),
    ),
  );
}
